#ifndef _SHAPE_H_
#define _SHAPE_H_

#include "differential_geometry.h"


typedef struct  
{
	unsigned shape_type;
	unsigned memory_start;
}shape_info_t;

enum ShapeType{TRIANGLE_VERTEX8=1,TRIANGLE_VERTEX16=2, TRIANGLE_VERTEX32=4};
enum ShapeShadingInfo{
	TRIANGLE_VERTEX_INDEX=0,
	TRIANGLE_VERTEX_INDEX_NORMAL = 1 << 4, 
	TRIANGLE_VERTEX_INDEX_TANGENT = 2 << 4, 
	TRIANGLE_VERTEX_INDEX_UVS = 4 << 4
};



INLINE void UniformSampleSphere(const float u1, const float u2, vector3f_t *v) {
	const float zz = 1.f - 2.f * u1;
	const float r = sqrt(max(0.f, (1.f - zz * zz)));
	const float phi = 2.f * FLOAT_PI * u2;
	const float xx = r * cos(phi);
	const float yy = r * sin(phi);
	vinit(*v, xx, yy, zz);
}

INLINE unsigned GetShapeIndexType(shape_info_t shape_info)
{
	return shape_info.shape_type & 0x0000000f;
}
INLINE unsigned GetShapeExtraInfo(unsigned shape_type)
{
	return (shape_type & 0x000000f0);
}
#endif
